from django.conf.urls.defaults import *

from codewiki.views_code import *
from codewiki.views_scope import *
from codewiki.views_api import *

import codewiki.views_code as views_code
import codewiki.views_scope as views_scope
import codewiki.views_api as views_api


import settings

from django.contrib import admin
admin.autodiscover()

# change ScrapedText to Reading and make it retrieve the data directly from the file instead of storing it
# collectors should make django tables (difficult)
# move hungary and pdf handling from farmsubsidy/
# remove all log files references


urlpatterns = patterns('',
    url(r'^admin/(.*)', admin.site.root, name="admin"),
    url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': os.path.join(settings.CODEWIKI_DIR, 'media'), 'show_indexes':True}),
    url(r'^media-admin/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': os.path.join(settings.CODEWIKI_DIR + 'media-admin'), 'show_indexes':True}),
    #(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    
    url(r'^$', views_scope.scopeindex, name="index"), 

    url(r'^(?P<dirname>(?:readers|detectors|collectors|observers))(?:/(?P<subdirname>.+?))?/$', views_code.codewikidir,  name="codewikidir"),
    url(r'^(?P<dirname>(?:readers|detectors|collectors|observers))/(?P<filename>.+?\.py)$',     views_code.codewikipage, name="codewikifile"),
    url(r'^reading/(?P<pageid>\d+)$',                           views_code.readingeditpageid, name="readingedit"),
    url(r'^reading/(?P<pageid>\d+)\.(?P<fileext>\.html|\.pdf|\.xml)$',    views_code.readingrawpageid,  name="readingraw"),
    url(r'^readings/$', views_code.readingsall, name="readingsall"),
    url(r'^observation/(?P<observername>.+?)(?:/(?P<tail>.+?))?$', views_api.observer,           name="observer"), 
                    
    #(r'^codewiki/(?P<dirname>(?:.*?/|))$', codewikidir),
    #(r'^codewiki/(?P<filename>.*)$', codewikipage),

# rest of these are obsolete
        
    # these should be written as "read"
    (r'^scraped/(?P<scraper_tag>.*?)/(?P<name>.*)$', scrapertextpage),
    (r'^scrapedview/(?P<scraper_tag>.*?)/(?P<name>.*)$', scrapertextpageview),
    (r'^scraped/(?P<scraper_tag>.*)$', scrapertags),

            
    # the key-value database will be under 'detected'
    (r'^scope/user/(?P<username>.*)/(?P<sourcename>.*)$', scopeusersourcename), 
    (r'^scope/user/(?P<username>.*)$', scopeuser), 
    (r'^scope/submit$', scopesubmit), 
    (r'^scope/users$', scopeusers), 
    (r'^scope/scroll$', scopescroll), 
    (r'^scope/about$', scopeabout), 
    (r'^scope/mappingapi.kml(?P<param>.*)$', scopemappingapi), 
    (r'^scope/api/1(?:/(?P<param1>.*))?(?:/(?P<param2>.*))?(?:/(?P<param3>.*))?$', scopeapi1), 
    (r'^scope/api/2(?:/(?P<param1>.*))?(?:/(?P<param2>.*))?(?:/(?P<param3>.*))?$', scopeapi2), 
    (r'^scope$', scopeindex), 
)

